<?php

declare(strict_types=1);

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateGqVideoCameraTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('gq_video_camera', function (Blueprint $table) {
            $table->id()->comment('主键ID');
            $table->string('name', 100)->comment('摄像头名称');
            $table->integer('type')->default(1)->comment('摄像头类型');
            $table->string('short_name', 50)->comment('摄像头简称');
            $table->string('device_code', 50)->unique()->comment('设备编号');
            $table->string('device_serial', 100)->comment('设备序列号');
            $table->string('manufacturer', 100)->comment('厂家');
            $table->string('ip_address', 15)->comment('IP地址');
            $table->integer('port')->default(554)->comment('端口号');
            $table->string('username', 50)->comment('账户');
            $table->string('password')->comment('密码');
            $table->text('play_url')->comment('播放地址(RTSP/FLV)');
            $table->string('location')->comment('位置');
            $table->decimal('longitude', 10, 7)->nullable()->comment('经度坐标');
            $table->decimal('latitude', 10, 7)->nullable()->comment('纬度坐标');
            $table->tinyInteger('status')->default(1)->comment('状态: 1=在线, 0=离线');
            $table->timestamps();
            
            // 添加索引
            $table->index(['status'], 'idx_status');
            $table->index(['manufacturer'], 'idx_manufacturer');
            $table->index(['ip_address'], 'idx_ip_address');
            
            $table->comment('摄像头设备管理表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('gq_video_camera');
    }
} 